<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>分公司增加</title>
<link rel="stylesheet" type="text/css"
	href="../../layui/css/layui.css" media="all">
<script type="text/javascript" src="../../res/js/jquery-1.10.2.js"></script>
<style type="text/css">
	body{
		margin:20px 0px;
	}
	#cd{
		width:300px;
	}
</style>
</head>
<body>
	<fieldset class="layui-elem-field layui-field-title"
		style="margin-top: 20px;">
		<legend>增加分公司</legend>
	</fieldset>

	<form class="layui-form" action="../../filiale/add.action" method="post">
		<div class="layui-form-item">
			<div class="layui-inline">
				<label class="layui-form-label">名称</label>
				<div class="layui-input-inline">
					<input type="text" name="filName" id="filName" required
						lay-verify="required" placeholder="分公司名称" autocomplete="off" 
						maxlength="50" class="layui-input">
					<p id="name"></p>
				</div>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-inline">
				<label class="layui-form-label">地址</label>
				<div class="layui-input-inline">
					<input type="text" name="filSite" id="filSite" required
						lay-verify="required" placeholder="地址" maxlength="30"
						autocomplete="off" class="layui-input">
				</div>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-inline">
				<label class="layui-form-label">管理人</label>
				<div class="layui-input-inline">
					<input type="text" name="filPreson" id="filPreson" required
						lay-verify="required" maxlength="10" placeholder="管理人"
						autocomplete="off" class="layui-input">
				</div>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-input-block">
				<input type="submit" class="layui-btn" lay-submit=""
					lay-filter="Add" value="立即增加">
				<button type="reset" class="layui-btn layui-btn-primary">重置</button>
			</div>
		</div>
	</form>
	<script src="../../layui/layui.js"></script>
	<script type="text/javascript">
		layui.use('form', function(){
			  var form = layui.form
			  ,layer = layui.layer
			  ,$ = layui.$;
			  
				$("#filName").blur(function(){
					var filName=$("#filName").val();
			  		var url = "../../filiale/isExist.action";
					var data={filName:filName};
					$.post(url,data,function(msg){
						if(msg=="no"){
							$("#name").html("");
						}else{
							$("#name").html("<font color='red'>该用户名已经存在!</font>");
							$("#filName").val("");
						}
					});
				});
			
			form.on('submit(Add)',function(){
				parent.location.reload(); // 父页面刷新
			});
		});
	</script>
</body>
</html>